<html>

<head>
  <script src="subresources/script.js"></script>
</head>

<body>
  <script type="text/javascript">

    // Returns the child frame url for the given |host|.
    function getChildFrameUrl(host) {
      var url = '';

      // Scheme.
      url += window.location.protocol + '//';

      // Host.
      url += host

      // Port.
      if (window.location.port)
        url += ':' + window.location.port;

      // Path.
      url += '/not_a_valid_child_frame.html';

      return url;
    }

    function main() {
      // Append 4 iframes named frame_[1..4] from hosts frame_[1..4].com.
      for (var i = 1; i <= 4; ++i) {
        var iframe = document.createElement('iframe');
        var frameName = 'frame_' + i;
        var frameHost = frameName + '.com';
        iframe.src = getChildFrameUrl(frameHost);
        iframe.name = frameName;
        document.body.appendChild(iframe);
      }
    }

    main();
  </script>
</body>

</html>
